<?php

class Zend_View_Helper_JavascriptHelper extends Zend_View_Helper_Abstract
{
	function javascriptHelper()
	{
		$request = Zend_Controller_Front::getInstance()->getRequest();
		$controllerName = $request->getControllerName();
		$actionName = $request->getActionName();
		foreach($this->view->getScriptPaths() as $path)
		{
			$fileName = $path . $controllerName . DIRECTORY_SEPARATOR . $actionName . '.js';
			if (file_exists($fileName)) {
                                $script = file_get_contents($fileName);
                                $this->view->headScript()->appendScript($script);
			}
		}
        }
}
